/**
 * 字典
 */
K.defDI("com.joypard.platform.dict.DictDI", {
	statics : {
		urls : {
			getChildren : $path + "/dict/getChildren.do",
			updateDict : $path + "/dict/updateDict.do",
			addDict : $path + "/dict/addDict.do",
			delDict : $path + "/dict/delDict.do",
			getDictRoot : $path + "/dict/getDictRoot.do",
		},

		getDictRoot : function() {
			var output = K.syncAjax(this.urls.getDictRoot);
			return output.getParameter("dict");
		},

		createDictRootAsyncTreeNode : function() {
			var root = this.getDictRoot();
			root.text = "【" + root.code + "】" + root.name;
			root.leaf = root.leaf == 1;
			return new K.Ext.tree.AsyncTreeNode(root);
		},

		createDictTreeLoader : function() {
			var treeStore = new K.Ext.tree.TreeLoader({
				url : this.urls.getChildren,
				listeners : {
					beforeload : function(loader, node) {
						this.baseParams.dictId = node.attributes.id;
					}
				},
				createNode : function(attr) {
					attr.text = attr.name;
					attr.text = "【" + attr.code + "】" + attr.name;
					attr.leaf = attr.leaf == 1;
					return K.Ext.tree.TreeLoader.prototype.createNode.call(this, attr);
				}
			});
			return treeStore;
		}
	}
});